package com.fzz.learning_forum.controller;

import com.fzz.learning_forum.domain.User;
import com.fzz.learning_forum.service.UserService;
import com.fzz.learning_forum.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    @Autowired
    private UserService userService=new UserServiceImpl();
    @RequestMapping(value = "/login")
    public String login(HttpSession session,String username, String password)
    {
        User user = userService.userLogin(username, password);
        System.out.println(user);
        if(user!=null)
        {
            session.setAttribute("user",user);
            return "redirect:/user/";
        }
        return "comm/login";
    }
}
